package com.zzyl.config;

import com.zzyl.intercept.MobileInterceptor;
import com.zzyl.intercept.WebInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * WebMvc高级配置类
 */
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    @Autowired
    private MobileInterceptor mobileInterceptor;
    @Autowired
    private WebInterceptor webInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
//        移动端拦截器
        registry.addInterceptor(mobileInterceptor)
                .addPathPatterns("/customer/**")                    //拦截路径
                .excludePathPatterns("/customer/user/login");       //放行路径

//        管理端拦截器
        registry.addInterceptor(webInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/customer/**","/security/login","/common/upload",
                        "/security/logout","/doc.html","/swagger-resources/**",
                        "/webjars/**", "/v2/**", "/swagger-ui.html/**");; //不拦截小程序端路径和网页端登陆、swagger接口文档
    }



}
